<template>
  <div id="app">
    <Toptab :key="topbarkey" />
    <Header />
    <router-view />
    <Footer />
    <Login v-show="isShowLoginModal"></Login>
    <transition name="fade">
      <Toast v-show="isShowToast" />
    </transition>
  </div>
</template>


<script>
import Toptab from "./components/Toptabbar.vue";
import Header from "./components/Header.vue";
import Footer from "./components/Footer.vue";
import Login from "./components/Login.vue";
import Toast from "./components/Toast.vue";

import { mapState } from "vuex";
export default {
  components: {
    Toptab,
    Header,
    Footer,
    Login,
    Toast,
  },
  computed: {
    ...mapState({
      isShowLoginModal: (state) => state.showModal.isShowLoginModal,
      isShowToast: (state) => state.showToast.isShowToast,
    }),
  },
  data() {
    return {
      topbarkey: 0,
    };
  },
  watch: {
    "$route.path": {
      handler() {
        //如何让组件重新加载  重新执行创建的钩子函数   解决   修改它的key值
        this.topbarkey++; //修改而来topbar醉驾案的key值  从而让组件重新加载
      },
    },
  },
};
</script>

<style lang="less">
.fade-enter,
.fade-leave-to {
  opacity: 0;
}
.fade-enter-active,
.fade-leave-active {
  transition: opacity 1s linear;
}
.fade-enter-to,
.fade-leave {
  opacity: 1;
}
</style>
